package cn.iocoder.yudao.module.signature.dal.mysql.developeraccount;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.signature.controller.admin.developeraccount.vo.DeveloperAccountPageReqVO;
import cn.iocoder.yudao.module.signature.dal.dataobject.developeraccount.DeveloperAccountDO;
import cn.iocoder.yudao.module.signature.model.GetAvailableAccountModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 苹果开发者账号 Mapper
 *
 * @author base
 */
@Mapper
public interface DeveloperAccountMapper extends BaseMapperX<DeveloperAccountDO> {

    default PageResult<DeveloperAccountDO> selectPage(DeveloperAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeveloperAccountDO>()
                .eqIfPresent(DeveloperAccountDO::getDeveloperAccount, reqVO.getDeveloperAccount())
                .eqIfPresent(DeveloperAccountDO::getIssId, reqVO.getIssId())
                .eqIfPresent(DeveloperAccountDO::getKId, reqVO.getKId())
                .eqIfPresent(DeveloperAccountDO::getCId, reqVO.getCId())
                .eqIfPresent(DeveloperAccountDO::getBId, reqVO.getBId())
                .likeIfPresent(DeveloperAccountDO::getDeveloperName, reqVO.getDeveloperName())
                .betweenIfPresent(DeveloperAccountDO::getExpireDate, reqVO.getExpireDate())
                .eqIfPresent(DeveloperAccountDO::getAccountBelongType, reqVO.getAccountBelongType())
                .eqIfPresent(DeveloperAccountDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(DeveloperAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeveloperAccountDO::getId));
    }

    DeveloperAccountDO getAvailableDeveloperAccount(@Param("model") GetAvailableAccountModel model);
}